/*
 * Copyright (c) Scrap Material Junior Brother, Xin. 2023-2023. All rights reserved.
 */

package collection;

import java.util.LinkedList;

/**
 * LinkedList实现栈和队列
 *
 * @author xin
 * @since 2023-05-02
 */
public class LinkedListApi {
    public static void main(String[] args) {
        LinkedList<Character> list = new LinkedList<>();
        list.add('A');
        System.out.println(list);
        list.add('B');
        System.out.println(list);
        list.addFirst('C');
        System.out.println(list);
        list.addLast('D');
        System.out.println(list);
        // 查看首位，不移除
        System.out.println(list.getFirst());
        // 查看末位，不移除
        System.out.println(list.getLast());
        // 移除首位
        list.removeFirst();
        System.out.println(list);
        // 移除末位
        list.removeLast();
        System.out.println(list);
        System.out.println(list.isEmpty());
    }
}
